Question about main(String[] args) [migrated]
Posted
by
Andrew0085
on Programmers
See other posts from Programmers
or by Andrew0085
Published on 2012-10-14T07:15:41Z
Indexed on
2012/10/14
9:50 UTC
Read the original article
Hit count: 97
java
I'm new to programming, and I'm using java. Here's a program I wrote:
class HelloApp {
static String hi;
public static void main(String[] args) {
int length = args.length;
if (length > 0) {
hi = args[0];
sayHi();
}
}
static void sayHi() {
if (hi == "hello") {
System.out.println("Hello!");
}
}
}
My question is: Why doesn't inputting "java HelloApp hello" make "Hello!" appear on the next line?
© Programmers or respective owner